<template>
  <el-dialog
    width="1200px"
    :title="$t('m.difference.info')"
    :visible.sync="dialogVisible"
    :before-close="close"
    :close-on-click-modal="false"
  >
    <el-form ref="form" label-width="180px">
      <el-row>
        <el-col :span="12">
          <el-form-item :label="$t('m.page.location')">
            <el-input v-model="detail.locationcode" disabled></el-input>
          </el-form-item>
        </el-col>
        <el-col :span="12">
          <el-form-item label="SKU">
            <el-input v-model="detail.productspeccode" disabled></el-input>
          </el-form-item>
        </el-col>
        <el-col :span="12">
          <el-form-item :label="$t('m.in.productname')">
            <el-input v-model="detail.productname" disabled></el-input>
          </el-form-item>
        </el-col>
        <el-col :span="12">
          <el-form-item :label="$t('m.in.productspec')">
            <el-input v-model="detail.productspec" disabled></el-input>
          </el-form-item>
        </el-col>
      </el-row>
      <el-divider>{{ $t("m.difference.differ") }}</el-divider>
      <el-row>
        <el-col :span="12">
          <el-form-item :label="$t('m.difference.differ')">
            <el-input v-model="differFilters" disabled></el-input>
          </el-form-item>
        </el-col>
        <el-col :span="12">
          <el-form-item :label="$t('m.difference.numbers')">
            <el-input v-model="detail.sourcecode" disabled></el-input>
          </el-form-item>
        </el-col>
        <el-col :span="12">
          <el-form-item :label="$t('m.difference.systemstock')">
            <el-input v-model="detail.systemstorage" disabled></el-input>
          </el-form-item>
        </el-col>
        <el-col :span="12">
          <el-form-item :label="$t('m.difference.actual')">
            <el-input v-model="detail.stocktakestorage" disabled></el-input>
          </el-form-item>
        </el-col>
        <el-col :span="12">
          <el-form-item :label="$t('m.difference.picked')">
            <el-input v-model="detail.unpackedstorage" disabled></el-input>
          </el-form-item>
        </el-col>
        <!-- 差异数 -->
        <el-col :span="12">
          <el-form-item :label="$t('m.difference.count')">
            <el-input v-model="differComputed" disabled></el-input>
          </el-form-item>
        </el-col>
        <el-col :span="12">
          <el-form-item :label="$t('m.stock.creator')">
            <el-input v-model="detail.creator" disabled></el-input>
          </el-form-item>
        </el-col>
        <el-col :span="12">
          <el-form-item :label="$t('m.stock.createdate')">
            <el-input v-model="createdateComputed" disabled></el-input>
          </el-form-item>
        </el-col>
      </el-row>
      <el-divider>{{ $t("m.difference.result") }}</el-divider>
      <el-row>
        <el-col :span="12">
          <el-form-item :label="$t('m.difference.result')">
            <el-input v-model="resultFilters" disabled></el-input>
          </el-form-item>
        </el-col>
        <el-col :span="12">
          <el-form-item :label="$t('m.difference.inventorycode')">
            <el-input v-model="detail.stocktakecode" disabled></el-input>
          </el-form-item>
        </el-col>
        <el-col :span="12">
          <el-form-item :label="$t('m.stock.creator')">
            <el-input v-model="detail.modifier" disabled></el-input>
          </el-form-item>
        </el-col>
        <el-col :span="12">
          <el-form-item :label="$t('m.stock.createdate')">
            <el-input v-model="modifydateComputed" disabled></el-input>
          </el-form-item>
        </el-col>
      </el-row>
    </el-form>
    <el-row>
      <el-button @click="close">{{ $t("m.close") }}</el-button>
    </el-row>
  </el-dialog>
</template>
<script>
import common from '@/utils/common'

export default {
  name:'difference-popup',
  props:['dialogVisible', 'detail','stockOptions'],
  data(){
    return {
      stocktype:0, // 盘点类型
      btnDisabled:false,
      btnLoading:false // 控制按钮loading，防止重复提交
    }
  },
  mounted(){
  },

  computed:{
    createdateComputed:{
      get(){
        return common.timestampToTime(this.detail.createdate)
      }
    },
    modifydateComputed:{
      get(){
        return common.timestampToTime(this.detail.modifydate)
      }
    },
    // 差异
    differFilters(){
      return this.detail.source===1?this.$t('m.difference.state3'):(this.detail.source===2?this.$t('m.difference.state4'):this.$t('m.difference.state5'))
    },
    // 处理结果
    resultFilters(){
      let result = this.stockOptions[1].find((item)=>{
        return item.value === this.detail.processingresult
      })
      return result?result.label:''

    },
    // 差异数
    differComputed(){
      let result = this.detail.stocktakestorage+this.detail.unpackedstorage-this.detail.systemstorage
      return result>0?'+'+result:result
    }
  },
  methods:{
    close(){
      this.$emit('close')
    }
  }
}
</script>
<style lang="scss" scoped>
.el-divider__text {
  font-size: 18px;
}
</style>